﻿// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

using NSQL.Sharpen;

namespace NSQL.Expressions.Functions
{
    public class CastFunction : BaseExpression, ICastFunction
    {
        public IExpression Expr { get; }
        public string TargetType { get; }

        public CastFunction(IExpression expr, string targetType)
        {
            Expr = expr;
            TargetType = targetType;
        }
        
        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.Visit(this);
        public override void Accept(IExpressionVisitor visitor) => visitor.Visit(this);
        public override bool IsValid => Expr.IsValid;
        protected override IExpression DeepCopy()
        {
            return new CastFunction(Expr.DeepClone(), TargetType)
            {
                Tag = Tag
            };
        }
    }
}